#pragma once

namespace BFX
{

class REFUTF16Encoding : public REFEncoding
{
public:
	REFUTF16Encoding(bool bBigEndian = false);
	virtual ~REFUTF16Encoding();

	//
	// Overrides
	//
	virtual int GetMaxByteCount(int nCharCount) const;
	virtual int GetMaxCharCount(int nByteCount) const;
	virtual int GetByteCount(const UCHAR* pChars, int nCount) const;
	virtual int GetBytes(const UCHAR* pChars, int nCharCount, OUT BYTE* pBytes, int nByteCount) const;
	virtual int GetCharCount(const BYTE* pBytes, int nCount, REFDecoder* pDecoder) const;
	virtual int GetChars(const BYTE* pBytes, int nByteCount, OUT UCHAR* pChars, int nCharCount, REFDecoder* pDecoder) const;

	virtual REFDecoder* GetDecoder() const;

protected:
	class UTF16Decoder : public REFDecoder
	{
	public:
		UTF16Decoder(const REFEncoding* pEncoding);
		virtual ~UTF16Decoder();
		virtual void Reset();

		int	m_lastByte;
		UCHAR	m_lastChar;
	};

protected:
	bool	m_bBigEndian;
};

}	//	namespace BFX
